In [1]:
using Symata # enter Symata mode
In [2]:
VersionInfo()
In [3]:
? OutputStyle
In [4]:
Timing(Range(10^5), Null) # jit compile
Timing(Range(10^5), Null)
Out[4]:
? prints help on the Help function.
Help(topic), Help("topic"), or ? topic prints documentation for topic.
h"words" does a case insensitive search of the contents of help documents.
Syamta uses the python package SymPy extensivley. Help prints relevant SymPy documentation along with Symata documentation. Type ShowSymPyDocs(False) to disable printing SymPy documentation.
In [5]:
2^100 # overflow
Out[5]:
In [6]:
? BigIntInput
In [7]:
BigIntInput(True);
In [8]:
2^100
Out[8]:
Note that this only applies to input integers (at the moment)
In [9]:
Head(Cos(Pi))
Out[9]:
In [10]:
Head(BI(Cos(Pi))) # Convert explicitly to BigInt
Out[10]:
Another way to parse a single number as a BigInt
In [11]:
BigIntInput(False)
big"2"^100
Out[11]:
Symata's host language is Julia. There are several ways to interact with Julia in a Symata session.
Julia and Symata keep separate lists of symbols. For instance, x may be defined in Julia, but not Symata, and vice versa.
Use SetJ to bind (i.e. set) a Julia symbol to a Symata expression.
In [12]:
? SetJ
In [13]:
expr = x + y
Out[13]:
Bind the Julia variable z to the result of evaluating expr.
In [14]:
SetJ(z , expr)
Out[14]:
Execute Julia code, by enclosing it in J( ). We ask for the value of z.
In [15]:
J(Main.z)
Out[15]:
We can also leave Symata and return to Julia
In [16]:
Julia() # begin interpreting expressions as Julia code. ;
In [17]:
z # Now in Julia
Out[17]:
The unexported Julia function symval returns the Symata binding of a symbol.
In [18]:
? Symata.symval
In [19]:
Symata.symval(:expr)
Out[19]:
We can do the reverse, set a Symata variable to the value of a Julia variable.
Set a variable in Jula.
In [20]:
a = 1 # Set a Julia symbol (bind an identifier to a value)
Out[20]:
In [21]:
isymata() # Enter Symata mode again
In [22]:
expr2 = J( Main.a )
expr2
Out[22]:
Symata symbol expr2 is now set to 1.
Use Symata's help search feature to find commands related to SymPy.
In [23]:
h"sympy"
In [24]:
? SymPyError
For debugging, you can disable converting SymPy objects to Symata.
In [25]:
? ReturnSymPy
In [26]:
? ToSymata
In [27]:
? ToSymPy
Use ToSymPy and ToSymata to convert between the languages.
In [28]:
OutputStyle(InputForm)
pyobj = ToSymPy(Integrate(f(x),x))
Out[28]:
In [29]:
OutputStyle(JupyterForm)
[Head(pyobj), PyHead(pyobj)]
Out[29]:
Recover the Symata expression.
In [30]:
ToSymata(pyobj)
Out[30]:
In [31]:
VersionInfo()
In [32]:
InputForm(Now())
Out[32]: